<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>DataExtractor: E:/cas/cas.0.7.0/sfw/src/MinConsole/MinConsole.0.8.0/MinConsole/Gaf/Utils/IO/FileUtility.cs Source File</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<link href="../../doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.2 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul class="tablist">
      <li><a href="../../index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="../../namespaces.html"><span>Packages</span></a></li>
      <li><a href="../../annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="../../files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs2">
    <ul class="tablist">
      <li><a href="../../files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<h1>E:/cas/cas.0.7.0/sfw/src/MinConsole/MinConsole.0.8.0/MinConsole/Gaf/Utils/IO/FileUtility.cs</h1>  </div>
</div>
<div class="contents">
<a href="../../d2/dad/FileUtility_8cs.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ﻿using System;
<a name="l00002"></a>00002 <span class="keyword">using</span> System.IO;
<a name="l00003"></a>00003 <span class="keyword">using</span> System.Text;
<a name="l00004"></a>00004 
<a name="l00005"></a>00005 
<a name="l00006"></a><a class="code" href="../../db/da1/namespaceMinConsole_1_1Gaf_1_1IO.html">00006</a> <span class="keyword">namespace </span>MinConsole.Gaf.IO
<a name="l00007"></a>00007 {
<a name="l00008"></a>00008     
<a name="l00013"></a><a class="code" href="../../d2/de1/classMinConsole_1_1Gaf_1_1IO_1_1FileUtility.html">00013</a>     <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">class </span><a class="code" href="../../d2/de1/classMinConsole_1_1Gaf_1_1IO_1_1FileUtility.html" title="Summary for the Files class &amp;lt;source&amp;gt;Subsonic 2.1 final&amp;lt;/source&amp;gt;">FileUtility</a>
<a name="l00014"></a>00014     {
<a name="l00020"></a><a class="code" href="../../d2/de1/classMinConsole_1_1Gaf_1_1IO_1_1FileUtility.html#a4ae4b7787ed54a00de8fdac52587e086">00020</a>         <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">string</span> GetFileText(<span class="keywordtype">string</span> absolutePath)
<a name="l00021"></a>00021         {
<a name="l00022"></a>00022             <span class="keyword">using</span> (StreamReader sr = <span class="keyword">new</span> StreamReader(absolutePath))
<a name="l00023"></a>00023                 <span class="keywordflow">return</span> sr.ReadToEnd();
<a name="l00024"></a>00024         }
<a name="l00025"></a>00025 
<a name="l00031"></a><a class="code" href="../../d2/de1/classMinConsole_1_1Gaf_1_1IO_1_1FileUtility.html#a3d21d6ef65e4d861be40650ffb68bea9">00031</a>         <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">void</span> CreateToFile(<span class="keywordtype">string</span> absolutePath, <span class="keywordtype">string</span> fileText)
<a name="l00032"></a>00032         {
<a name="l00033"></a>00033             <span class="keyword">using</span> (StreamWriter sw = File.CreateText(absolutePath))
<a name="l00034"></a>00034                 sw.Write(fileText);
<a name="l00035"></a>00035         }
<a name="l00036"></a>00036 
<a name="l00043"></a><a class="code" href="../../d2/de1/classMinConsole_1_1Gaf_1_1IO_1_1FileUtility.html#aafb077d985e7c663e0252a18acb1423c">00043</a>         <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">void</span> UpdateFileText(<span class="keywordtype">string</span> absolutePath, <span class="keywordtype">string</span> lookFor, <span class="keywordtype">string</span> replaceWith)
<a name="l00044"></a>00044         {
<a name="l00045"></a>00045             <span class="keywordtype">string</span> newText = GetFileText(absolutePath).Replace(lookFor, replaceWith);
<a name="l00046"></a>00046             WriteToFile(absolutePath, newText);
<a name="l00047"></a>00047         }
<a name="l00048"></a>00048 
<a name="l00054"></a><a class="code" href="../../d2/de1/classMinConsole_1_1Gaf_1_1IO_1_1FileUtility.html#a8cd07ba8171c34ba86465634e4d20c0b">00054</a>         <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">void</span> WriteToFile(<span class="keywordtype">string</span> absolutePath, <span class="keywordtype">string</span> fileText)
<a name="l00055"></a>00055         {
<a name="l00056"></a>00056             <span class="keyword">using</span> (StreamWriter sw = <span class="keyword">new</span> StreamWriter(absolutePath, <span class="keyword">false</span>))
<a name="l00057"></a>00057             {
<a name="l00058"></a>00058                 sw.Write(fileText);
<a name="l00059"></a>00059                 sw.Flush(); 
<a name="l00060"></a>00060                      
<a name="l00061"></a>00061             } <span class="comment">//eof using </span>
<a name="l00062"></a>00062         }
<a name="l00063"></a>00063 
<a name="l00064"></a>00064 
<a name="l00070"></a><a class="code" href="../../d2/de1/classMinConsole_1_1Gaf_1_1IO_1_1FileUtility.html#aa861aac4a79749e1b44c734f040059da">00070</a>         <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">void</span> AppendToFile(<span class="keywordtype">string</span> absolutePath , <span class="keywordtype">string</span> txt) 
<a name="l00071"></a>00071         {
<a name="l00072"></a>00072             <span class="keyword">using</span> (StreamWriter sw = File.AppendText(absolutePath))
<a name="l00073"></a>00073             {
<a name="l00074"></a>00074                 sw.WriteLine(txt);
<a name="l00075"></a>00075                 sw.Flush(); 
<a name="l00076"></a>00076             } <span class="comment">//eof using </span>
<a name="l00077"></a>00077         } <span class="comment">//eof method </span>
<a name="l00078"></a>00078 
<a name="l00079"></a>00079 
<a name="l00084"></a><a class="code" href="../../d2/de1/classMinConsole_1_1Gaf_1_1IO_1_1FileUtility.html#a4b0dbe797914229886fb15ce09d8c6bd">00084</a>         <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">string</span> CreateProcessDefaultIniFile()
<a name="l00085"></a>00085         {
<a name="l00086"></a>00086             <span class="keywordtype">string</span> strIniFilePath = String.Empty;
<a name="l00087"></a>00087             <span class="keywordtype">string</span> strPathToExe = Environment.GetCommandLineArgs()[0];
<a name="l00088"></a>00088             <span class="keywordtype">string</span> extension = Path.GetExtension(strPathToExe);
<a name="l00089"></a>00089             <span class="comment">//string filename = Path.GetFileName(strPathToExe);</span>
<a name="l00090"></a>00090             <span class="keywordtype">string</span> strBaseDir = Path.GetDirectoryName(strPathToExe);
<a name="l00091"></a>00091             <span class="keywordtype">string</span> strMachineName = System.Environment.MachineName;
<a name="l00092"></a>00092             <span class="keywordtype">string</span> fileNameNoExtension = Path.GetFileNameWithoutExtension(strPathToExe);
<a name="l00093"></a>00093             <span class="comment">//now build the default ini file path </span>
<a name="l00094"></a>00094             strIniFilePath = strBaseDir + <span class="stringliteral">@&quot;\&quot;</span> + strMachineName + <span class="stringliteral">&quot;.&quot;</span> + fileNameNoExtension + <span class="stringliteral">&quot;.ini&quot;</span>;
<a name="l00095"></a>00095 
<a name="l00096"></a>00096             <span class="keywordflow">return</span> strIniFilePath;
<a name="l00097"></a>00097         } <span class="comment">//eof method </span>
<a name="l00098"></a>00098 
<a name="l00099"></a>00099 
<a name="l00104"></a><a class="code" href="../../d2/de1/classMinConsole_1_1Gaf_1_1IO_1_1FileUtility.html#ab9c7dbca1066ee54db8f9b1208cfdb40">00104</a>         <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">string</span> CreateProcessDefaultLogFile()
<a name="l00105"></a>00105         {
<a name="l00106"></a>00106             <span class="keywordtype">string</span> strIniFilePath = String.Empty;
<a name="l00107"></a>00107             <span class="keywordtype">string</span> strPathToExe = Environment.GetCommandLineArgs()[0];
<a name="l00108"></a>00108             <span class="keywordtype">string</span> extension = Path.GetExtension(strPathToExe);
<a name="l00109"></a>00109             <span class="comment">//string filename = Path.GetFileName(strPathToExe);</span>
<a name="l00110"></a>00110             <span class="keywordtype">string</span> strBaseDir = Path.GetDirectoryName(strPathToExe);
<a name="l00111"></a>00111             <span class="keywordtype">string</span> strMachineName = System.Environment.MachineName;
<a name="l00112"></a>00112             <span class="keywordtype">string</span> fileNameNoExtension = Path.GetFileNameWithoutExtension(strPathToExe);
<a name="l00113"></a>00113             <span class="comment">//now build the default ini file path </span>
<a name="l00114"></a>00114             <span class="keywordtype">string</span> strDatePattern = DateTime.Now.ToString(<span class="stringliteral">&quot;yyyy.MM.dd&quot;</span>);
<a name="l00115"></a>00115             strIniFilePath = strBaseDir + <span class="stringliteral">@&quot;\&quot;</span> + strMachineName + <span class="stringliteral">&quot;.&quot;</span> + fileNameNoExtension + strDatePattern + <span class="stringliteral">&quot;.log&quot;</span>;
<a name="l00116"></a>00116 
<a name="l00117"></a>00117             <span class="keywordflow">return</span> strIniFilePath;
<a name="l00118"></a>00118         } <span class="comment">//eof method </span>
<a name="l00119"></a>00119 
<a name="l00120"></a>00120 
<a name="l00121"></a>00121 
<a name="l00122"></a>00122 
<a name="l00123"></a>00123 
<a name="l00124"></a>00124 
<a name="l00125"></a>00125     } <span class="comment">//eof clas </span>
<a name="l00126"></a>00126 } <span class="comment">//eof namespace </span>
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Sat Jan 22 2011 22:24:47 for DataExtractor by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="../../doxygen.png" alt="doxygen"/></a> 1.7.2 </small></address>
</body>
</html>
